<?php
/**
 * Created by PhpStorm.
 * User: MrHung
 * Date: 5/12/14
 * Time: 11:27 AM
 */

namespace Admin\Model;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;


class AdminPage {

    public $id;
    public $title;
    public $content;
    public $page_date;
    public $author;
    public $status;
    public $page_parent;
    public $page_order;
    public $page_type;
    public $slug;

    protected $inputfilter;


    public function exchangeArray($data){

        $this->id     = (isset($data['id'])) ? $data['id'] : null;
        $this->title = (isset($data['title'])) ? $data['title'] : null;
        $this->content  = (isset($data['content'])) ? $data['content'] : null;

        $this->page_date = (isset($data['page_date'])) ? $data['page_date'] : time();
        $this->author = (isset($data['author'])) ? $data['author'] : null;
        $this->status  = (isset($data['status'])) ? $data['status'] : 'closed';

        $this->page_parent     = (isset($data['page_parent'])) ? $data['page_parent'] : 0;
        $this->page_order = (isset($data['page_order'])) ? $data['page_order'] : null;
        $this->page_type  = (isset($data['page_type'])) ? $data['page_type'] : 'post';
        $this->slug  = (isset($data['slug'])) ? $data['slug'] : null;
    }

    public function getInputFilter() {
        if (!$this->inputFilter) {
            $inputFilter = new InputFilter();
            $factory     = new InputFactory();

            $inputFilter->add($factory->createInput(array(
                'title'     => 'title',
                'required' => true,
            )));

            $inputFilter->add($factory->createInput(array(
                'content'     => 'content',
                'required' => false,
            )));



            $this->inputFilter = $inputFilter;
        }

        return $this->inputFilter;
    }
} 